#include <bits/stdc++.h>
#define int long long
using namespace std;

int sx[100005], v0[100005], v1[100005];
int c[100005];

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int t, n, m, l, vmax;
	int lsx = 0, maxl = 0, ans1 = 0, ans2 = 0;
	cin >> t;
	while (t--)
	{
		ans1 = 0, ans2 = 0, lsx = 0, maxl = 0;
		cin >> n >> m >> l >> vmax;
		for (int i = 1; i <= n; i++)
		{
			cin >> sx[i] >> v0[i] >> v1[i];
		}	
		for (int i = 1; i <= m; i++)
		{
			cin >> c[i];
			lsx = max(lsx, c[i]);
		}
		
		for (int i = 1; i <= n; i++)
		{
			if (v1[i] == 0)
			{
				if (v0[i] > vmax) //chaosu
				{
					ans1++;
					maxl = max(maxl, sx[i]);
				}
			}
			else 
			{
				if (v1[i] > 0)
				{
					int ex = floor(1.0 * (vmax * vmax - v0[i] * v0[i]) / (v1[i] * 2)) + 1 + sx[i];
					if (ex <= lsx) //chaosu
					{
						ans1++;
						maxl = max(maxl, ex);
					}
				}
			}
		}
		if (maxl == 0) maxl = INT_MAX;
		for (int i = 1; i <= m; i++)
			if (c[i] < maxl) ans2++;
		cout << ans1 << " " << ans2 << "\n";
	}
	return 0;
}
